<?php

namespace V1;
class PublicList extends \ResourceClass
{
    public $isActive = true;
    public $remark = '我的发布';

    public function get(array $req, array $post, &$result)
    {
        if (!isset($req['uid'])) {
            return 'uid require';
        }else{
            $where = "uid = {$req['uid']}";
        }
        try {
            $result = array();
            $article_list = new \Orm\Article\ArticleList();
            $article_list['l'] = isset($req['l']) ? $req['l'] : \Util\Config::get('default_limit');
            $article_list['o'] = isset($req['o']) ? $req['o'] : \Util\Config::get('default_offset');
            $article_list['where'] = $where;
            $order = 'update_time desc';
            $article_list['order'] = $order;
            $article_list->load();
            foreach ($article_list['lists'] as $id => $list){
                $result[$id]['id'] = (string)$list['id'];
                $result[$id]['uid'] = (string)$list['uid'];
                $result[$id]['title'] = (string)$list['title'];
                $result[$id]['img'] = (string)$list['img'];
                $result[$id]['remark'] = (string)$list['remark'];
                $result[$id]['insert_time'] = (string)$list['insert_time'];
                $result[$id]['update_time'] = (string)$list['update_time'];
            }
        } catch (\Base\Exception\MysqlErrorException $e) {
            return '服务器内部错误';
        } catch (\Exception $e) {
            return $e->getMessage();
        }
    }
}